package test;

import java.util.Scanner;

public class Home {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        System.out.println("输入几个数字：");
        int flag = scan.nextInt();
        int num = 0,sum = 0,count;
        for (int i = 0;i<flag;i++){
            num = scan.nextInt();
            try {
                if (num<0) throw new Exception("N必须是正数或者0");
            }catch (Exception e){
                e.getStackTrace();
                System.out.println(e.getMessage());
                System.out.println("用户再次输入该数");
                num = scan.nextInt();
            }finally {
                sum+=num;
            }
        }
        int avg = sum/flag;
        System.out.println(avg);
    }
}
